home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d20 / loge_006.arc / LOGENTRY.C next >
Text File  |  1990-12-19  |  1KB  |  37 lines

  1. /*                 Write a passed entry to a log                */
  2. /* Format of call is: LOGENTRY filename a xxxxxxx xxxxxxxxx xxxxxx    */
  3. /* filename is the file that will be appended                    */
  4. /* a is the loglevel of the message (1 character)                    */
  5. /* xxxxxxxx is the message to be written to the file                */
  6. /* 0.05 Added display for info being written to file                */
  7. /* 0.06 Added Date and Time to log entry                        */
  8. #include <stdio.h>
  9. #include <dos.h>
  10. void main(int numparms, char *parm[])
  11. {
  12. struct date today;
  13. struct time now;
  14.  
  15. char version[]="0.06",
  16.     months[12][4] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
  17.  
  18. int    i;
  19.  
  20. FILE    *log_fp;
  21.  
  22.     getdate(&today);
  23.     gettime(&now);
  24.     log_fp = fopen(parm[1], "a");
  25.     printf ("Logentry V%s %s %s", version, parm[1], parm[2]);
  26.     fprintf(log_fp, "%1s %02d %3s ", parm[2], today.da_day, months[today.da_mon-1]);
  27.     fprintf(log_fp, "%02d:%02d:%02d", now.ti_hour, now.ti_min, now.ti_sec);
  28.     for (i=3; i<numparms; i++)
  29.     {
  30.         fprintf(log_fp, " %s", parm[i]);
  31.         printf(" %s", parm[i]);
  32.     }
  33.     fprintf(log_fp, "\n");
  34.     printf("\n");
  35.     fclose (log_fp);
  36.     exit(0);
  37. }